package com.example.rlw.mvpplugintest.login;

import com.example.rlw.mvpplugintest.bean.UserBean;
import com.example.rlw.mvpplugintest.mvp.BaseObserver;
import com.example.rlw.mvpplugintest.mvp.BaseObserver2;
import com.example.rlw.mvpplugintest.mvp.BasePresenterImpl;
import com.example.rlw.mvpplugintest.mvp.CallBack;
import com.example.rlw.mvpplugintest.mvp.MyObservableTransformer;
import com.example.rlw.mvpplugintest.net.HttpResponseData;
import com.example.rlw.mvpplugintest.net.HttpService;
import com.example.rlw.mvpplugintest.net.NetWorks;

import java.util.List;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * 登录presenter
 */

public class LoginPresenter extends BasePresenterImpl<LoginContract.View> implements LoginContract.Presenter {

    @Override
    public void login(String userName, String userPwd) {
        //直接 presenter 中 处理数据
        NetWorks.configRetrofit(HttpService.class).login(userName, userPwd)
                .compose(new MyObservableTransformer<HttpResponseData<List<UserBean>>>())
                .subscribe(new BaseObserver<List<UserBean>>(getView(), this) {
                    @Override
                    public void onSuccess(List<UserBean> data) {
                        getView().loginSuccess(data);
                    }
                });

    }
}
